package com.synjones.cominterface;

import android.os.Build;

import com.synjones.handsetS8.S8Interface;
import com.synjones.handsetS8L.BIInterface;

public class ReaderInterfaceFactory {
	public static final int READER_NONE=-1;
	public static final int READER_BLUETOOTH=0;
	public static final int READER_HANDSET_718D=1;//718d handset
	public static final int READER_SERIAL=2;
	public static final int READER_USB=3;
	public static final int READER_USB_2303SERIAL=4;
	public static final int READER_S8=5;
	public static final int READER_BI =6;
	private static  int WHICH_READER=READER_NONE;

	public static final String READER_INTERFACE[]={"蓝牙","718D手持机","串口","USB OTG","USB2303转串口","S8手持机","S8(L1)手持机"};

    public static int getWhichReader(){
        return WHICH_READER;
    }

	public static void setWhichReader(int whichReader) {
		WHICH_READER = whichReader;
	}

	public static int findDeviceModel(){
		String model=new Build().MODEL;
		if(model.equals("hsimobile77_jb")){
			return ReaderInterfaceFactory.READER_HANDSET_718D;
		}
		if(model.equals("len6735_65u_m")||model.equalsIgnoreCase("SynjonesS8")||model.equalsIgnoreCase("SynjonesS9")
				||model.equals("len6737t_66_m0"))
			return ReaderInterfaceFactory.READER_S8;
		if(model.equals("PDA")|| model.equals("S8E(L1)"))
			return ReaderInterfaceFactory.READER_BI;

		return READER_NONE;
	}

	public static ReaderInterface create(){

    	if(WHICH_READER==READER_NONE){
			WHICH_READER=findDeviceModel();
		}
		switch (WHICH_READER) {
			case READER_BI:
				return new BIInterface();
			case READER_S8:
				return new S8Interface();
		default:
			break;
		}
		return new BIInterface();
	}
}
